package tests;

import static org.junit.Assert.*;

import java.awt.Color;

import MULE.Model.Game;
import MULE.Model.Map;
import MULE.Model.Map.MapType;
import MULE.Model.Player;
import MULE.Model.PlayerColor;
import MULE.Model.Race;
import MULE.Model.Logic.PlayerConfigLogic;
import MULE.Model.Panel.PlayerConfigPanel;

import org.junit.Before;
import org.junit.Test;

/**
 * This class tests a PlayerNameIsAvailable method.

 * @ author Aaron Englebardt @ version 1.0 11.18.2013
 */
/**
 * Cases to check for: 1) Pass empty string "" into PlayerNameIsAvailable, test
 * if the output is false as it should be 2) Pass unavailable (taken) String
 * into PlayerNameIsAvailable, test if the output is false as it should be. 3)
 * Pass available String into PlayerNameIsAvailable, test if the output is true
 * as it should be.
 */
public class PlayerNameIsAvailableTest {
	private PlayerConfigLogic pCL;
	private PlayerConfigPanel view;
	private Game game;

	/**
	 * Sets up the tests we will run
	 */
	@Before
	public void setUp() {
		Player p1 = new Player(1, "Jenkins", Race.HUMAN, Color.RED);
		Player p2 = new Player(2, "Bob", Race.HUMAN, Color.BLUE);
		view = new PlayerConfigPanel(Race.getRaceNames(),
				PlayerColor.getColorNames());
		pCL = new PlayerConfigLogic(view);
		game = new Game(3, Game.getDifficulty("Beginner"), new Map(
				MapType.DEFAULT));
		pCL.setGame(game);
		try {
			game.addPlayer(p1);
			game.addPlayer(p2);
		} catch (Exception e) {
		}
	}

	/**
	 * Tests the empty String "".
	 */
	@Test
	public void test1() {

		Boolean bool = pCL.playerNameIsAvailable("");
		assertTrue(!bool);
	}

	/**
	 * Tests the unavailable String "Bob".
	 */
	@Test
	public void test2() {
		Boolean bool = pCL.playerNameIsAvailable("Bob");
		assertTrue(!bool);
	}

	/**
	 * Tests the available String "Schwartz".
	 */
	@Test
	public void test3() {
		Boolean bool = pCL.playerNameIsAvailable("Schwartz");
		assertTrue(bool);
	}
}
